// components/shop-subject/shop-subject.js
let app = getApp();
Component({

  options: {
    addGlobalClass: true,//使用app.wxss样式
  },
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    items: [],
    currentSwiper: 0,
  },

  lifetimes: {
    ready() {
//      this.getItems();
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {
    swiperChange(event){
      this.setData({
        currentSwiper: event.detail.current
      })
    },

    itemClick(event){
      let id = event.currentTarget.dataset.id;
      let name = event.currentTarget.dataset.name;
      wx.navigateTo({
        url: '/pages/classify/classify-children/classify-children?id=' + id + '&name=' + name,
      })
    },

    getItems(){
      let _this = this;
      let user = app.getUser();
      let tCentreId = wx.getStorageSync('tempCentreId');
      wx.request({
        url: app.globalData.deployUrl + '/wxapi/shop/subject',
        method: 'GET',
        data: {
          type: 4,
          centreId: app.globalData.loginCentreId
        },
        success: (res) => {
          if (res.data.success){
            let temp = res.data.data.filter(item => item.parentId !== 10);
            let cc = [];
            for (let i = 0; i < temp.length; i += 10) {//每10条数据循环一次
              cc.push({citem: temp.slice(i, i + 10)});
            }
            _this.setData({
              items: cc
            })
          }
        }
      });
    },
  }
})
